#!/usr/bin/env python
PACKAGE = "aruco_detect"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

gen.add("adaptiveThreshConstant",                 double_t, 0, 
        "Constant for adaptive thresholding before finding contours",
         7, 0)

gen.add("adaptiveThreshWinSizeMin",               int_t,    0,
        "Minimum window size for adaptive thresholding before finding contours",
         3, 1)

gen.add("adaptiveThreshWinSizeMax",               int_t,    0,
        "Maximum window size for adaptive thresholding before finding contours",
        53, 1)

gen.add("adaptiveThreshWinSizeStep",              int_t,    0,
        "Increments from adaptiveThreshWinSizeMin to adaptiveThreshWinSizeMax during the thresholding",
         4, 1)

gen.add("cornerRefinementMaxIterations",          int_t,    0,
        "Maximum number of iterations for stop criteria of the corner refinement process",
        30, 1)

gen.add("cornerRefinementMinAccuracy",            double_t, 0,
        "Minimum error for the stop criteria of the corner refinement process",
        0.01, 0, 1)

gen.add("cornerRefinementWinSize",                int_t,    0,
        "Window size for the corner refinement process (in pixels)",
         5, 1)

gen.add("doCornerRefinement",                     bool_t,   0,
        "Whether to do subpixel corner refinement",
         True)

gen.add("errorCorrectionRate",                    double_t, 0,
        "Error correction rate respect to the maximum error correction capability for each dictionary",
        0.6, 0, 1)

gen.add("minCornerDistanceRate",                  double_t, 0,
        "Minimum distance between corners for detected markers relative to its perimeter",
        0.05, 0)

gen.add("markerBorderBits",                       int_t,    0,
        "Number of bits of the marker border, i.e. marker border width",
        1, 0)

gen.add("maxErroneousBitsInBorderRate",           double_t, 0,
        "Maximum number of accepted erroneous bits in the border (i.e. number of allowed white bits in the border)",
       0.04, 0, 1)

gen.add("minDistanceToBorder",                    int_t,    0,
        "Minimum distance of any corner to the image border for detected markers (in pixels)",
        3, 0)

gen.add("minMarkerDistanceRate",                  double_t, 0,
        "minimum mean distance beetween two marker corners to be considered similar, so that the smaller one is removed. The rate is relative to the smaller perimeter of the two markers",
        0.1, 0, 1)

gen.add("minMarkerPerimeterRate",                 double_t, 0,
        "Determine minumum perimeter for marker contour to be detected. This is defined as a rate respect to the maximum dimension of the input image",
        0.03, 0, 1)

gen.add("maxMarkerPerimeterRate",                 double_t, 0,
        "Determine maximum perimeter for marker contour to be detected. This is defined as a rate respect to the maximum dimension of the input image",
        4.0, 0, 1)

gen.add("minOtsuStdDev",                          double_t, 0,
        "Minimun standard deviation in pixels values during the decodification step to apply Otsu thresholding (otherwise, all the bits are set to 0 or 1 depending on mean higher than 128 or not)",
        5.0, 0)      

gen.add("perspectiveRemoveIgnoredMarginPerCell",  double_t, 0,
        "Width of the margin of pixels on each cell not considered for the determination of the cell bit. Represents the rate respect to the total size of the cell, i.e. perpectiveRemovePixelPerCell",
        0.13, 0, 1)

gen.add("perspectiveRemovePixelPerCell",          int_t,    0,
        "Number of bits (per dimension) for each cell of the marker when removing the perspective",
        8, 1)

gen.add("polygonalApproxAccuracyRate",            double_t, 0,
        "Minimum accuracy during the polygonal approximation process to determine which contours are squares",
        0.01, 0, 1)

exit(gen.generate(PACKAGE, "aruco_detect", "DetectorParams"))
